package cn.edu.zafu.bigdata.x.sxy;

public abstract class Shape {
    public abstract double area();
    public abstract double perimeter();
    public final void display(){
        System.out.println("The area is: " + area());
        System.out.println("The perimeter is: " + perimeter());
    }
}

class Circle extends Shape{
    private double radius;
    public Circle(double radius){
        this.radius = radius;
    }
    @Override
    public double area(){
        return Math.PI * radius * radius;
    }

    @Override
    public double perimeter(){
        return 2 * Math.PI * radius;
    }
}

class Rectangle extends Shape{
    private double length;
    private double width;
    public Rectangle(double length, double width){
        this.length = length;
        this.width = width;
    }
    @Override
    public double area(){
        return length * width;
    }
    @Override
    public double perimeter(){
        return 2 * (length +width);
    }
}
